package com.cxps.cloud.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * 订单状态 枚举类
 *
 * @author YouCai.Liu
 * @since 2021/10/8
 * ...
 */
public enum OrderStatus {

    UNPAID("0", "待支付"),
    OK_PAY("1", "已支付"),
    ERR_PAY("2", "支付失败"),
    REFUND("3", "退款中"),
    CLOSE("4", "已关闭");

    private final static Map<String, OrderStatus> CODE_MAP = new HashMap();
    private final static Map<String, OrderStatus> NAME_MAP = new HashMap();

    static {
        for (OrderStatus status : values()) {
            CODE_MAP.put(status.getCode(), status);
            NAME_MAP.put(status.getName(), status);
        }
    }

    private String code;

    private String name;

    OrderStatus(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public static OrderStatus getEnumByCode(String code) {
        return CODE_MAP.get(code);
    }

    public static OrderStatus getEnumByName(String name) {
        return NAME_MAP.get(name);
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }
}
